package com.student.xujiang.myallstudent.mrecyclerview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.student.xujiang.R;

import java.util.ArrayList;
import java.util.List;

public class RecyclerMainActivity extends AppCompatActivity {

    //为了解耦 就不用注解了，毕竟注解也需要学习时间
    private RecyclerView mRecyclerView;
    //让Adapter可以获取数据
    private List<String> mDatas;
    public List<String> getmDatas() {
        return mDatas;
    }
    public void setmDatas(List<String> mDatas) {
        this.mDatas = mDatas;
    }


    private RecyclerViewAdapter mAdapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_main);

        initData();

        mRecyclerView = (RecyclerView) findViewById(R.id.id_recyclerview);
        //确定你的布局，在这里是线性布局
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        //设置Adapter
        mAdapter = new RecyclerViewAdapter(this,mDatas);
        mRecyclerView.setAdapter(mAdapter);

    }

    protected void initData(){
        mDatas = new ArrayList<String>();
        for(int i='A' ;i<'z';i++)
        {
            mDatas.add(""+(char) i);
        }
    }
}
